home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / getfil2r / form1.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1999-08-16  |  17.6 KB  |  612 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   5010
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   8970
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   5010
  10.    ScaleWidth      =   8970
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.TextBox txtNumPoints 
  13.       Height          =   285
  14.       Left            =   1755
  15.       TabIndex        =   18
  16.       Text            =   "1024"
  17.       Top             =   4050
  18.       Width           =   735
  19.    End
  20.    Begin VB.Frame Frame3 
  21.       Caption         =   "Smoothing Algorithm"
  22.       Height          =   1140
  23.       Left            =   135
  24.       TabIndex        =   15
  25.       Top             =   90
  26.       Width           =   2850
  27.       Begin VB.OptionButton Option1 
  28.          Caption         =   "FFT"
  29.          Height          =   195
  30.          Index           =   1
  31.          Left            =   225
  32.          TabIndex        =   17
  33.          Top             =   720
  34.          Width           =   2040
  35.       End
  36.       Begin VB.OptionButton Option1 
  37.          Caption         =   "Savitzky-Golay"
  38.          Height          =   375
  39.          Index           =   0
  40.          Left            =   225
  41.          TabIndex        =   16
  42.          Top             =   270
  43.          Width           =   2040
  44.       End
  45.    End
  46.    Begin VB.TextBox txtRandom 
  47.       Height          =   330
  48.       Left            =   7200
  49.       TabIndex        =   11
  50.       Text            =   "1"
  51.       Top             =   4545
  52.       Width           =   510
  53.    End
  54.    Begin VB.CommandButton CmdCreateData 
  55.       Caption         =   "Reset Data"
  56.       Height          =   375
  57.       Left            =   3375
  58.       TabIndex        =   1
  59.       Top             =   4500
  60.       Width           =   2445
  61.    End
  62.    Begin VB.PictureBox Pic1 
  63.       BackColor       =   &H80000005&
  64.       Height          =   4200
  65.       Left            =   3195
  66.       ScaleHeight     =   4140
  67.       ScaleWidth      =   5535
  68.       TabIndex        =   0
  69.       Top             =   135
  70.       Width           =   5595
  71.    End
  72.    Begin VB.Frame Frame2 
  73.       Caption         =   "FFT Smooth"
  74.       Height          =   2490
  75.       Left            =   135
  76.       TabIndex        =   7
  77.       Top             =   1350
  78.       Width           =   2895
  79.       Begin VB.HScrollBar HScroll1 
  80.          Height          =   285
  81.          Left            =   135
  82.          Max             =   1024
  83.          Min             =   2
  84.          TabIndex        =   8
  85.          Top             =   1440
  86.          Value           =   100
  87.          Width           =   2535
  88.       End
  89.       Begin VB.Label Label4 
  90.          Caption         =   "Move the scroll bar to smooth using the FFT algorithm"
  91.          Height          =   510
  92.          Left            =   315
  93.          TabIndex        =   14
  94.          Top             =   405
  95.          Width           =   2355
  96.       End
  97.       Begin VB.Label Lblfft 
  98.          AutoSize        =   -1  'True
  99.          Caption         =   "Frequency Cut-Off:  2 %"
  100.          Height          =   195
  101.          Left            =   585
  102.          TabIndex        =   9
  103.          Top             =   1125
  104.          Width           =   1680
  105.       End
  106.    End
  107.    Begin VB.Frame Frame1 
  108.       Caption         =   "Savitzky-Golay Smoothing"
  109.       Height          =   2490
  110.       Left            =   135
  111.       TabIndex        =   2
  112.       Top             =   1350
  113.       Width           =   2895
  114.       Begin VB.CommandButton CmdSG2 
  115.          Caption         =   "Cumulative Smoothing"
  116.          Enabled         =   0   'False
  117.          Height          =   375
  118.          Left            =   180
  119.          TabIndex        =   12
  120.          Top             =   1935
  121.          Width           =   2175
  122.       End
  123.       Begin VB.CommandButton Cmdsg1 
  124.          Caption         =   "Smooth Data"
  125.          Height          =   375
  126.          Left            =   180
  127.          TabIndex        =   6
  128.          Top             =   1440
  129.          Width           =   2175
  130.       End
  131.       Begin VB.ComboBox CboSavGol 
  132.          Height          =   315
  133.          Left            =   1665
  134.          Style           =   2  'Dropdown List
  135.          TabIndex        =   5
  136.          Top             =   405
  137.          Width           =   1095
  138.       End
  139.       Begin VB.CheckBox ChkLog 
  140.          Caption         =   "Log Data"
  141.          Height          =   375
  142.          Left            =   180
  143.          TabIndex        =   4
  144.          ToolTipText     =   "Useful for positive data, spanning several orders of magnitude"
  145.          Top             =   855
  146.          Width           =   1905
  147.       End
  148.       Begin VB.Label Label1 
  149.          Caption         =   "Smoothing Window:"
  150.          Height          =   285
  151.          Left            =   180
  152.          TabIndex        =   3
  153.          Top             =   450
  154.          Width           =   1590
  155.       End
  156.    End
  157.    Begin VB.Label Label6 
  158.       Caption         =   "For speed in FFT, use a power of 2 for the number of points"
  159.       Height          =   420
  160.       Left            =   45
  161.       TabIndex        =   20
  162.       Top             =   4500
  163.       Width           =   2805
  164.    End
  165.    Begin VB.Label Label5 
  166.       Caption         =   "Number of Points:"
  167.       Height          =   240
  168.       Left            =   270
  169.       TabIndex        =   19
  170.       Top             =   4095
  171.       Width           =   1680
  172.    End
  173.    Begin VB.Label Label3 
  174.       Caption         =   "(1 - 5)"
  175.       Height          =   330
  176.       Left            =   7830
  177.       TabIndex        =   13
  178.       Top             =   4590
  179.       Width           =   915
  180.    End
  181.    Begin VB.Label Label2 
  182.       Caption         =   "Randomness:"
  183.       Height          =   330
  184.       Left            =   6075
  185.       TabIndex        =   10
  186.       Top             =   4590
  187.       Width           =   1680
  188.    End
  189. Attribute VB_Name = "Form1"
  190. Attribute VB_GlobalNameSpace = False
  191. Attribute VB_Creatable = False
  192. Attribute VB_PredeclaredId = True
  193. Attribute VB_Exposed = False
  194. Option Explicit
  195. 'Dynamic data arrays
  196. Dim DataX() As Double
  197. Dim DataY() As Double
  198. Dim SmoothedY() As Double
  199. Dim DataI() As Double
  200. Private Const PI As Double = 3.14159265358979
  201. Dim NP As Integer
  202. Dim SmoothCount As Integer
  203. 'The matrix for the Savitzky-Golay Coefficents
  204. 'These are filled in the form load event
  205. Dim SGCoef(1 To 11, 0 To 13) As Integer
  206. Private Sub CmdCreateData_Click()
  207. Dim i As Integer
  208. Dim Ymin As Double, Ymax As Double
  209. Dim RandFactor As Double
  210. Randomize
  211. Ymin = 0
  212. Ymax = 0
  213. RandFactor = Val(txtRandom)
  214. NP = Val(txtNumPoints)
  215. HScroll1.Max = NP
  216. ReDim DataX(1 To NP)
  217. ReDim DataY(1 To NP)
  218. ReDim SmoothedY(1 To NP)
  219. ReDim DataI(1 To NP)
  220. For i = 1 To NP
  221.   DataX(i) = i
  222.   DataI(i) = 0
  223.   DataY(i) = Sin(i / NP * 4 * PI) + 0.5 * Sin(i / NP * 40 * PI) + RandFactor * Rnd + 4
  224.   If DataY(i) > Ymax Then Ymax = DataY(i)
  225.   If DataY(i) < Ymin Then Ymin = DataY(i)
  226. Pic1.ScaleLeft = 0
  227. Pic1.ScaleWidth = NP
  228. Pic1.ScaleTop = Ymax + Ymax * 0.1
  229. Pic1.ScaleHeight = ((Ymax - Ymin)) * -1
  230. GraphData DataY
  231. SmoothCount = 0
  232. If Option1(0).Value Then
  233.   Me.Caption = "Savitzky-Golay Smoothing"
  234.   Me.Caption = "FFT Smoothing"
  235. End If
  236. CmdSG2.Enabled = False
  237. HScroll1.SmallChange = NP / 100
  238. HScroll1.LargeChange = NP / 20
  239. End Sub
  240. Private Sub Cmdsg1_Click()
  241. Call SavGolSmooth(CboSavGol.ListIndex + 2, False)
  242. Me.Caption = "Smoothed " & SmoothCount & " time"
  243. GraphData SmoothedY
  244. End Sub
  245. Private Sub CmdSG2_Click()
  246. Call SavGolSmooth(CboSavGol.ListIndex + 2, True)
  247. Me.Caption = "Smoothed " & SmoothCount & " times"
  248. GraphData SmoothedY()
  249. End Sub
  250. Private Sub Form_Activate()
  251. Option1(0).Value = True
  252. End Sub
  253. Private Sub Form_Load()
  254. CboSavGol.Clear
  255. CboSavGol.AddItem "5 point"
  256. CboSavGol.AddItem "7 point"
  257. CboSavGol.AddItem "9 point"
  258. CboSavGol.AddItem "11 point"
  259. CboSavGol.AddItem "13 point"
  260. CboSavGol.AddItem "15 point"
  261. CboSavGol.AddItem "17 point"
  262. CboSavGol.AddItem "19 point"
  263. CboSavGol.AddItem "21 point"
  264. CboSavGol.AddItem "23 point"
  265. CboSavGol.AddItem "25 point"
  266. CboSavGol.ListIndex = 0
  267. 'Set the Smoothing Coefficients for Savitzky-Golay
  268. 'The zeroth value is the normalization factor
  269. SGCoef(1, 1) = 17
  270. SGCoef(1, 2) = 12
  271. SGCoef(1, 3) = -3
  272. SGCoef(1, 0) = 35
  273. SGCoef(2, 1) = 7
  274. SGCoef(2, 2) = 6
  275. SGCoef(2, 3) = 3
  276. SGCoef(2, 4) = -2
  277. SGCoef(2, 0) = 21
  278. SGCoef(3, 1) = 59
  279. SGCoef(3, 2) = 54
  280. SGCoef(3, 3) = 39
  281. SGCoef(3, 4) = 14
  282. SGCoef(3, 5) = -21
  283. SGCoef(3, 0) = 231
  284. SGCoef(4, 1) = 89
  285. SGCoef(4, 2) = 84
  286. SGCoef(4, 3) = 69
  287. SGCoef(4, 4) = 44
  288. SGCoef(4, 5) = 9
  289. SGCoef(4, 6) = -36
  290. SGCoef(4, 0) = 429
  291. SGCoef(5, 1) = 25
  292. SGCoef(5, 2) = 24
  293. SGCoef(5, 3) = 21
  294. SGCoef(5, 4) = 16
  295. SGCoef(5, 5) = 9
  296. SGCoef(5, 6) = 0
  297. SGCoef(5, 7) = -11
  298. SGCoef(5, 0) = 143
  299. SGCoef(6, 1) = 167
  300. SGCoef(6, 2) = 162
  301. SGCoef(6, 3) = 147
  302. SGCoef(6, 4) = 122
  303. SGCoef(6, 5) = 87
  304. SGCoef(6, 6) = 42
  305. SGCoef(6, 7) = -13
  306. SGCoef(6, 8) = -78
  307. SGCoef(6, 0) = 1105
  308. SGCoef(7, 1) = 43
  309. SGCoef(7, 2) = 42
  310. SGCoef(7, 3) = 39
  311. SGCoef(7, 4) = 34
  312. SGCoef(7, 5) = 27
  313. SGCoef(7, 6) = 18
  314. SGCoef(7, 7) = 7
  315. SGCoef(7, 8) = -6
  316. SGCoef(7, 9) = -21
  317. SGCoef(7, 0) = 323
  318. SGCoef(8, 1) = 269
  319. SGCoef(8, 2) = 264
  320. SGCoef(8, 3) = 249
  321. SGCoef(8, 4) = 224
  322. SGCoef(8, 5) = 189
  323. SGCoef(8, 6) = 144
  324. SGCoef(8, 7) = 89
  325. SGCoef(8, 8) = 24
  326. SGCoef(8, 9) = -51
  327. SGCoef(8, 10) = -136
  328. SGCoef(8, 0) = 2261
  329. SGCoef(9, 1) = 329
  330. SGCoef(9, 2) = 324
  331. SGCoef(9, 3) = 309
  332. SGCoef(9, 4) = 284
  333. SGCoef(9, 5) = 249
  334. SGCoef(9, 6) = 204
  335. SGCoef(9, 7) = 149
  336. SGCoef(9, 8) = 84
  337. SGCoef(9, 9) = 9
  338. SGCoef(9, 10) = -76
  339. SGCoef(9, 11) = -171
  340. SGCoef(9, 0) = 3059
  341. SGCoef(10, 1) = 79
  342. SGCoef(10, 2) = 78
  343. SGCoef(10, 3) = 75
  344. SGCoef(10, 4) = 70
  345. SGCoef(10, 5) = 63
  346. SGCoef(10, 6) = 54
  347. SGCoef(10, 7) = 43
  348. SGCoef(10, 8) = 30
  349. SGCoef(10, 9) = 15
  350. SGCoef(10, 10) = -2
  351. SGCoef(10, 11) = -21
  352. SGCoef(10, 12) = -42
  353. SGCoef(10, 0) = 806
  354. SGCoef(11, 1) = 467
  355. SGCoef(11, 2) = 462
  356. SGCoef(11, 3) = 447
  357. SGCoef(11, 4) = 422
  358. SGCoef(11, 5) = 387
  359. SGCoef(11, 6) = 322
  360. SGCoef(11, 7) = 287
  361. SGCoef(11, 8) = 222
  362. SGCoef(11, 9) = 147
  363. SGCoef(11, 10) = 62
  364. SGCoef(11, 11) = -33
  365. SGCoef(11, 12) = -138
  366. SGCoef(11, 13) = -253
  367. SGCoef(11, 0) = 5135
  368. End Sub
  369. Private Sub HScroll1_Change()
  370. Dim Keep As Integer
  371. Dim Power2 As Integer
  372. Dim tr() As Double, ti() As Double
  373. Dim i As Integer, J As Integer
  374. Dim NP_FFT As Integer
  375. Dim AvgVal As Double
  376. Lblfft = "Frequency Cut-off:  " & Format((HScroll1.Value / NP) * 100, "0") & " %"
  377. 'This procedure calculates the correct power of 2 to use, and calls the FFT
  378. 'routine as neccesary. The FFT algorithm always smooths the original data
  379. 'There is no cumulative smoothing
  380. For i = 1 To 14
  381.   If 2 ^ i >= NP Then
  382.     Power2 = i
  383.     Exit For
  384.   End If
  385. Next i
  386. NP_FFT = 2 ^ Power2
  387. ReDim tr(1 To NP_FFT)
  388. ReDim ti(1 To NP_FFT)
  389. If NP_FFT = NP Then
  390.   tr = DataY
  391.   ti = DataI
  392.   'We have to pad the array - I choose to pad the array with the average
  393.   'of the first and last data values
  394.   AvgVal = (DataY(i) + DataY(NP)) / 2
  395.    For i = 1 To NP_FFT
  396.    If i <= NP Then
  397.      tr(i) = DataY(i)
  398.      ti(i) = 0
  399.    Else
  400.      tr(i) = AvgVal
  401.      ti(i) = 0
  402.    End If
  403.  Next i
  404. End If
  405.   Keep = CInt(HScroll1.Value / 2)
  406.   'First call to get the imaginary data array sorted out
  407.   Call FFT(tr, ti, Power2, -1)
  408.       
  409.   For i = 1 + Keep To NP_FFT - Keep
  410.     tr(i) = 0
  411.     ti(i) = 0
  412.   Next
  413.   'This call will give us the smoothed data
  414.   Call FFT(tr, ti, Power2, 1)
  415.   'transfer FFT data to our smoothed Array  (deleted for speed!)
  416.   ReDim Preserve tr(1 To NP)
  417.   SmoothedY = tr
  418.   GraphData SmoothedY  'Graph the smoothed data
  419. End Sub
  420. Public Sub GraphData(Data() As Double)
  421. On Error Resume Next
  422. Dim i As Integer
  423. Pic1.Cls
  424. For i = 2 To UBound(Data)
  425.   Pic1.Line (i - 1, Data(i - 1))-(i, Data(i)), vbBlack
  426. End Sub
  427. Private Sub HScroll1_Scroll()
  428. 'Lblfft = "Frequency Cut-off:  " & Format(HScroll1.Value / 10.24, "0") & " %"
  429. HScroll1_Change
  430. End Sub
  431. Private Sub Option1_Click(Index As Integer)
  432. CmdCreateData_Click
  433. Frame2.Visible = (Index = 1)
  434. Frame1.Visible = (Index = 0)
  435. If Index = 1 Then
  436.   Me.Caption = "FFT Smoothing"
  437.   Me.Caption = "Savitzky-Golay Smoothing"
  438. End If
  439. End Sub
  440. Private Sub txtNumPoints_KeyPress(KeyAscii As Integer)
  441. If KeyAscii = 13 Then
  442.   If Val(txtNumPoints > 50) And Val(txtNumPoints < 5001) Then
  443.     CmdCreateData_Click
  444.   Else
  445.     txtNumPoints = 1024
  446.   End If
  447. ElseIf KeyAscii <> 8 Then
  448.   If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0
  449. End If
  450. End Sub
  451. Private Sub txtNumPoints_LostFocus()
  452. If Val(txtNumPoints) <> NP Then
  453.   CmdCreateData_Click
  454. End If
  455. End Sub
  456. Private Sub txtRandom_LostFocus()
  457. If Not IsNumeric(txtRandom) Then
  458.   MsgBox "You must enter a valid number for randomness"
  459.   txtRandom.SetFocus
  460.   Exit Sub
  461. End If
  462. If Val(txtRandom) < 0 Or Val(txtRandom) > 5 Then
  463.   txtRandom = 1
  464. End If
  465. End Sub
  466. Public Sub SavGolSmooth(Degree As Integer, CumulativeSmooth As Boolean)
  467. 'Savitzky_Golay Smoothing
  468. 'If SmoothCurrent is set to true, then the last smoothed data set will be smoothed,
  469. '(i.e. The new smoothing will be cumulative over the last smoothing operation.  If
  470. 'SmoothCurrent is false, then the original Y-data will be smoothed, and the smoothedY array will
  471. 'be overwritten
  472. 'The Aavitzky-Golay smoothing algorithm essentialy fits the data to a second order polynomial
  473. 'within a moving data window.  It assumes that the data has a fixed spacing in the x direction,
  474. 'but does work even if this is not the case.
  475. 'For more info see:
  476. '"Smoothing and Differentiation of Data by Simplified Least Squares Procedure",
  477. 'Abraham Savitzky and Marcel J. E. Golay, Analytical Chemistry, Vol. 36, No. 8, Page 1627 (1964)
  478. 'Degree 2 = 5 point
  479. 'Degree 3 = 7 point ...etc
  480. Dim i As Integer, J As Integer
  481. Dim TempSum As Double
  482. On Error Resume Next
  483. 'Logging the data is useful if the data is always above zero, and spans
  484. 'several orders of magnitude
  485. ReDim Temp(1 To NP) As Double
  486. If ChkLog.Value = 1 Then
  487.   If CumulativeSmooth Then
  488.     For i = 1 To NP
  489.       If SmoothedY(i) <> 0 Then
  490.         SmoothedY(i) = Log(SmoothedY(i))
  491.       Else
  492.         SmoothedY(i) = 0.000001
  493.       End If
  494.     Next i
  495.   Else
  496.     For i = 1 To NP
  497.       If DataY(i) <> 0 Then
  498.         DataY(i) = Log(DataY(i))
  499.       Else
  500.         DataY(i) = 0.000001
  501.       End If
  502.     Next i
  503.   End If
  504. End If
  505. If CumulativeSmooth = False Then
  506.   'we cannot smooth too close to the data bounds
  507.   For i = 1 To Degree
  508.     SmoothedY(i) = DataY(i)
  509.   Next i
  510.   For i = NP - (Degree + 1) To NP
  511.    SmoothedY(i) = DataY(i)
  512.   Next i
  513.   SmoothCount = 0
  514.   For i = 1 + Degree To NP - Degree
  515.     TempSum = DataY(i) * SGCoef(Degree - 1, 1)
  516.     For J = 1 To Degree
  517.       TempSum = TempSum + DataY(i - J) * (SGCoef(Degree - 1, J + 1))
  518.       TempSum = TempSum + DataY(i + J) * (SGCoef(Degree - 1, J + 1))
  519.      
  520.     Next J
  521.     SmoothedY(i) = TempSum / SGCoef(Degree - 1, 0)
  522.   Next i
  523.   'The last smoothed data will be used to create a new smoothed data set,
  524.   'therefore the smoothing operations will be additive
  525.   For i = 1 + Degree To NP - Degree
  526.     TempSum = SmoothedY(i) * SGCoef(Degree - 1, 1)
  527.     For J = 1 To Degree
  528.       TempSum = TempSum + SmoothedY(i - J) * (SGCoef(Degree - 1, J + 1))
  529.       TempSum = TempSum + SmoothedY(i + J) * (SGCoef(Degree - 1, J + 1))
  530.      
  531.     Next J
  532.     SmoothedY(i) = TempSum / SGCoef(Degree - 1, 0)
  533.   Next i
  534. End If
  535. If ChkLog.Value = 1 Then
  536.   If CumulativeSmooth Then
  537.     For i = 1 To NP
  538.       SmoothedY(i) = Exp(SmoothedY(i))
  539.     Next
  540.   Else
  541.     For i = 1 To NP
  542.       DataY(i) = Exp(DataY(i))
  543.       SmoothedY(i) = Exp(SmoothedY(i))
  544.     Next
  545.   End If
  546. End If
  547. SmoothCount = SmoothCount + 1
  548. CmdSG2.Enabled = True
  549. End Sub
  550. Public Sub FFT(FR() As Double, FI() As Double, LnN As Integer, sign As Integer)
  551. 'From "Image Processing" by Jan Teuber
  552. 'The major weakness of the FFT algoirthm is the requirement that the number of data points be
  553. 'a power of 2.  To work around this, I find the nearest power of 2 that is below the number of data points,
  554. 'then I smooth the first 2^N points.  Then the remaining points are smoothed, with at least 32 points.
  555. 'The second set of smoothed data is appended to the first set
  556. 'This algorithm slows down very fast as the number of points gets higher
  557. Dim nd2 As Integer
  558. Dim i As Integer, J As Integer, k As Integer, l As Integer
  559. Dim le As Integer, le1 As Integer
  560. Dim ip As Integer, NP_FFT As Integer
  561. Dim s As Double, ur As Double, ur1 As Double, ui As Double, wr As Double, wi As Double
  562. Dim tr As Double, ti As Double, DivN As Double
  563.   NP_FFT = 2 ^ LnN 'Number of points for use in FFT
  564.   nd2 = NP_FFT / 2  'Half points
  565.   J = 1
  566.   For i = 1 To NP_FFT - 1
  567.     If i < J Then
  568.       s = FR(i)
  569.       FR(i) = FR(J)
  570.       FR(J) = s
  571.       s = FI(i)
  572.       FI(i) = FI(J)
  573.       FI(J) = s
  574.     End If
  575.     k = nd2
  576.     While k < J
  577.       J = J - k
  578.       k = k / 2
  579.     Wend
  580.     J = J + k
  581.   Next i
  582.   For l = 1 To LnN
  583.     le = 2 ^ l
  584.     le1 = le / 2
  585.     ur = 1
  586.     ui = 0
  587.     wr = Cos(PI / le1)
  588.     wi = sign * Sin(PI / le1)
  589.     For J = 1 To le1
  590.       i = J
  591.       While (i <= NP_FFT)
  592.         ip = i + le1
  593.         tr = FR(ip) * ur - FI(ip) * ui
  594.         ti = FR(ip) * ui + FI(ip) * ur
  595.         FR(ip) = FR(i) - tr
  596.         FI(ip) = FI(i) - ti
  597.         FR(i) = FR(i) + tr
  598.         FI(i) = FI(i) + ti
  599.         i = i + le
  600.       Wend
  601.       ur1 = ur * wr - ui * wi
  602.       ui = ur * wi + ui * wr
  603.       ur = ur1
  604.     Next
  605.   Next   '{l - l
  606. DivN = 1 / Sqr(NP_FFT)
  607.  For i = 1 To NP_FFT
  608.    FR(i) = FR(i) * DivN
  609.    FI(i) = FI(i) * DivN
  610.  Next i
  611. End Sub
  612.